import libtcodpy as libtcod

import ent
import events

class Crime(object):
	def __init__(self, owner):
		self.owner = owner
	
class Crimeplace(ent.Entity):
	def __init__(self, em, x, y, char, color):
		super(Crimeplace,self).__init__(em, x, y, char, color)
		
		self.crime = None
		
		
	def set_crime(crime):
		self.crime = crime


class Scent(ent.Entity):
	def __init__(self, em, x, y, char, color):
		super(Scent,self).__init__(em, x, y, char, color)
		
class Fingerprings(Scent):
	def __init__(self, em, x, y, char, color):
		super(Fingerprings,self).__init__(em, x, y, char, color)



class SocialController(events.EventListener):
	def __init__(self):
		super(SocialController,self).__init__()
		
	def register(self,em):
		crimeplaces = []
		em.register("crimeplaces",crimeplaces)

	def notify(self,event):
		objects = self.em.services["objects"]
		crimeplaces = self.em.services["crimeplaces"]

		#if isinstance(event,events.MurderEvent):
		if isinstance(event,events.NPCReportCrimeEvent):
			#cp = Crimeplace(self.em, event.victim.x, event.victim.y, 'C', libtcod.black)
			
			#check if no crimeplace is located there allready
			for obj in objects:
				if isinstance(obj, Crimeplace):
					return
			
			cp = Crimeplace(self.em, event.origin.x, event.origin.y, 'C', libtcod.black)
			cp.name = "CRIMEPLACE"
			objects.append(cp)
			crimeplaces.append(cp)
			
			#TODO1 : move objects to the object controller
			#TODO2 : let object controller send event notification to the object pool
			
			for object in objects:
				if hasattr(object,"notify"):
					object.notify(event)
					
			#-----------------------------------------------------------------------------
